package com.dcxt.view;

import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class sa extends Activity {
    private WebView webview;
    private DisplayMetrics dm;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().setLayout(dm.widthPixels, dm.heightPixels);
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

        setContentView(R.layout.main);

        webview = (WebView) findViewById(R.id.webview);
        // ����WebView���ԣ��ܹ�ִ��JavaScript�ű�
        webview.getSettings().setJavaScriptEnabled(true);
        // ����URL����
        webview.loadUrl("http://172.21.11.205:8098/cook/index.html");
        // ����web��ͼ�ͻ���
        webview.setWebViewClient(new MyWebViewClient());
    }

    // ���û���
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
            webview.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    // web��ͼ�ͻ���
    public class MyWebViewClient extends WebViewClient {
        public boolean shouldOverviewUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }
}